
//
//  AppDelegate+Facebook.m
//  WXReader
//
//  Created by LL on 2020/9/8.
//  Copyright © 2020 Andrew. All rights reserved.
//

#import "AppDelegate+Facebook.h"
//#import "TL_AppsFlyerManager.h"
#import <FBSDKLoginKit/FBSDKLoginKit.h>

@implementation AppDelegate (Facebook)

- (void)initFacebookWithApplication:(UIApplication *)application launchOptions:(NSDictionary *)launchOptions {
    
    // 设置Facebook App ID和Display Name
    [FBSDKSettings.sharedSettings setAppID:WX_Facebook_AppId];
//    [FBSDKSettings.sharedSettings setDisplayName:@"TainTale"];
    
    if (@available(iOS 14.0, *)) {
        [[FBSDKSettings sharedSettings] setAdvertiserTrackingEnabled:YES];
    }
    
    [[FBSDKSettings sharedSettings] setClientToken:WX_Facebook_Secret];
    
    [[FBSDKApplicationDelegate sharedInstance] application:application
    didFinishLaunchingWithOptions:launchOptions];
    
    if (launchOptions[UIApplicationLaunchOptionsURLKey] == nil) {
        // Get user consent
        [[FBSDKApplicationDelegate sharedInstance] initializeSDK];
            
        [FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url, NSError *error) {
//            [[TL_AppsFlyerManager sharedInstance] initAppsFlyerOnAppOpen:url.absoluteString];
            
//            NSString *channelString = url.absoluteString;
//            if (!kObjectIsEmpty(channelString)) {
//                [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%@_%@", channelString, @"facebook"] forKey:WX_Media_Source];
//            }
            
//            if ( self.tabBarControllerConfig.tabBarController.viewControllers.count > 0 && TL_UserInfoManager.isLogin) {
//                [[TL_AppsFlyerManager sharedInstance] deeplinkEvent];
//            }
        }];
    }
}

@end
